package telltale;

public class TellTale
{
	public static final TellTale LIFECYCLE = new TellTale();
	public static final TellTale BENCHMARK = new TellTale();
	public static final TellTale TRACE = new TellTale();
	public static final TellTale ERROR = new TellTale();

	public TellTale()
	{
		this( null );
	}
	
	public TellTale( Class clazz )
	{
		if( clazz == null )
		{
			Exception e = new Exception();
			StackTraceElement[] elements = e.getStackTrace();
			String loggerClazz = getClass().getName();
			loop:
			for( StackTraceElement element : elements )
			{
				if( element.getClassName().equals( loggerClazz )) continue;
				_longClass = element.getClassName();
				int nth = _longClass.lastIndexOf( '.' );
				_shortClass = _longClass.substring( nth + 1 );
				break loop;
			}
		}
		else
		{
			_longClass = clazz.getName();
			_shortClass = clazz.getSimpleName();
		}
	}
	

	private String _longClass;
	
	public String getLongClass()
	{
		return _longClass;
	}
	
	private String _shortClass;
	
	public String getShortClass()
	{
		return _shortClass;
	}
	
	private Adapter _logger = new SystemOutAdapter();
	
	public void setLogger( Adapter logger )
	{
		_logger = logger;
	}
	
	public Adapter getLogger()
	{
		return _logger;
	}
	
	public void log()
	{
		getLogger().log( this );
	}
	
	public void log( Object message )
	{
		getLogger().log( this, message );
	}
	
	public void log( String template, Object a )
	{
		getLogger().log( this, template, a );
	}
	
	public void log( String template, Object a, Object b )
	{
		getLogger().log( this, template, a, b );
	}
	
	public void log( String template, Object a, Object b, Object c )
	{
		getLogger().log( this, template, a, b, c );
	}
	
	public void log( String template, Object... a )
	{
		getLogger().log( this, template, a );
	}
	
	public void log( Throwable throwable )
	{
		getLogger().log( this, throwable );
	}
	
	public void log( Throwable throwable, Object message )
	{
		getLogger().log( this, throwable, message );
	}
	
	public void log( Throwable throwable, String template, Object a )
	{
		getLogger().log( this, throwable, template, a );
	}
	
	public void log( Throwable throwable, String template, Object a, Object b )
	{
		getLogger().log( this, throwable, template, a, b );
	}
	
	public void log( Throwable throwable, String template, Object a, Object b, Object c )
	{
		getLogger().log( this, throwable, template, a, b, c );
	}
	
	public void log( Throwable throwable, String template, Object... a )
	{
		getLogger().log( this, throwable, template, a );
	}

	
}
